package controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@CrossOrigin(originPatterns="*",allowCredentials="true",maxAge = 3600)
@Controller
public class Test {
	@RequestMapping("/test")
	@ResponseBody
	public String register(HttpServletResponse response,HttpSession session) {
		session.setAttribute("loginUserName", 6666);
		System.out.println(session.getAttribute("loginUserName"));
		System.out.println(session.getId());
//		System.out.println(request.getSession().getAttribute("loginUserName"));
//		request.getSession().setAttribute("loginUserName",6666);
//		System.out.println(request.getSession().getAttribute("loginUserName").toString());
//		System.out.println(request.getSession().getId());
		return session.getId().toString();
	}
}
